]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
keyboard: Do not create widgetry for all keyboard groups at once
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 23 Jan 2018 16:03:02 +0000 (17:03 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 5 Feb 2018 16:46:57 +0000 (17:46 +0100)
Instead do this on demand based on the current group. It is less
taxing at the time of initially creating the Keyboard object.

js/ui/keyboard.js

index 8fe392f0afb4df8158ec43d8469cc60b4084a04b..605af3b562c795b14c6f4a52d858ad379924224c 100644 (file)
@@ -680,7 +680,8 @@ var Keyboard = new Lang.Class({
                        { x_align: St.Align.MIDDLE,
                          x_fill: false });
 
-        this._addKeys();
+        this._ensureKeysForGroup(this._keyboardController.getCurrentGroup());
+        this._setActiveLayer(0);
 
         // Keyboard models are defined in LTR, we must override
         // the locale setting in order to avoid flipping the
@@ -744,14 +745,9 @@ var Keyboard = new Lang.Class({
         return layers;
     },
 
-    _addKeys: function () {
-        let groups = this._keyboardController.getGroups();
-        for (let i = 0; i < groups.length; ++i) {
-             let gname = groups[i];
-             this._groups[gname] = this._createLayersForGroup(gname);
-        }
-
-        this._setActiveLayer(0);
+    _ensureKeysForGroup: function(group) {
+        if (!this._groups[group])
+            this._groups[group] = this._createLayersForGroup(group);
     },
 
     _addRowKeys : function (keys, layout) {
@@ -911,6 +907,7 @@ var Keyboard = new Lang.Class({
     },
 
     _onGroupChanged: function () {
+        this._ensureKeysForGroup(this._keyboardController.getCurrentGroup());
         this._setActiveLayer(0);
     },